package com.swxy.club.service.record;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swxy.club.dto.CheckinRecord;
import com.swxy.club.mapper.CheckinRecordMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * @author 易
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class CheckinRecordServiceImpl extends ServiceImpl<CheckinRecordMapper, CheckinRecord> implements CheckinRecordService{


    @Override
    public CheckinRecord selectByUserId(Long userId, Integer activityId) {


        LambdaQueryWrapper<CheckinRecord> queryWrapper = new QueryWrapper<CheckinRecord>()
                .lambda()
                .eq(CheckinRecord::getUserId, userId)
                .eq(CheckinRecord::getActivityId, activityId);
        return this.getOne(queryWrapper);
    }

    @Override
    public void updateStatus(CheckinRecord record) {
        this.updateById(record);
    }

    @Override
    public void addCheckinRecord(CheckinRecord record) {
        this.save(record);
    }
}
